package org.example.router;

import org.example.handlers.PersonHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerResponse;

@Configuration
public class RouterConfig {

    @Bean
    public RouterFunction<ServerResponse> route(PersonHandler handler) {
        return RouterFunctions.route()
                .GET("/person",handler::getAllUser)
                .DELETE("/person/{id}", handler::deleteUserById)
                .POST("/person", handler::createUser)
                .build();
    }
}
